package com.geping.etl.config.job.impl;

import com.geping.etl.common.service.LogsSynService;
import com.geping.etl.config.job.JobTask;
import com.geping.etl.config.job.JobTaskRegister;
import com.geping.etl.utils.EnvUitl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/***
 *  日志定时器
 * @author liang.xu
 * @date 2023.7.25
 */
@Slf4j
@Component
public class LogJobTask extends JobTaskRegister implements JobTask {

    @Autowired
    private LogsSynService logsSynService;


    @Override
    public Runnable getTask() {
        return () -> {
            log.info("同步日志开始");
            try {
                logsSynService.updateLogs();
            } catch (Exception e) {
                log.error("日志同步失败---->",e);
            }
            log.info("同步日志结束");
        };
    }

    @Override
    public String getExpression() {
        String jobLogCron = EnvUitl.props.getProperty("job.log.cron");
        return jobLogCron;
    }
}